﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SafeLoad.NControl
{
  /// <summary>
  /// NInfo.xaml 的交互逻辑
  /// </summary>
  public partial class NInfo : UserControl
  {
    public NInfo()
    {
      InitializeComponent();
    }

    public static readonly DependencyProperty InfoProperty =
      DependencyProperty.Register("Info", typeof(string), typeof(NInfo), new PropertyMetadata(""));
    public string Info
    {
      get { return (string)GetValue(InfoProperty); }
      set { SetValue(InfoProperty, value); }
    }

    public static readonly DependencyProperty StateProperty =
      DependencyProperty.Register("State", typeof(string), typeof(NInfo), new PropertyMetadata("",
        new PropertyChangedCallback(RenderUpdateByPropertyChanged)));
    public string State
    {
      get { return (string)GetValue(StateProperty); }
      set { SetValue(StateProperty, value); }
    }

    public static readonly DependencyProperty StartTimeProperty =
      DependencyProperty.Register("StartTime", typeof(DateTime), typeof(NInfo), new PropertyMetadata(DateTime.MinValue,
        new PropertyChangedCallback(RenderUpdateByPropertyChanged)));
    public DateTime StartTime
    {
      get { return (DateTime)GetValue(StartTimeProperty); }
      set { SetValue(StartTimeProperty, value); }
    }

    public static readonly DependencyProperty IsTopProperty =
      DependencyProperty.Register("IsTop", typeof(bool), typeof(NInfo), new PropertyMetadata(false,
        new PropertyChangedCallback(RenderUpdateByPropertyChanged)));
    public bool IsTop
    {
      get { return (bool)GetValue(IsTopProperty); }
      set { SetValue(IsTopProperty, value); }
    }

    protected override void OnRender(DrawingContext drawingContext)
    {
      base.OnRender(drawingContext);
      NInfoUpdate();
    }

    public static void RenderUpdateByPropertyChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs e)
    {
      if (dependency is NInfo info)
      {
        info.NInfoUpdate();
      }
    }

    private void NInfoUpdate()
    {
      //canvas1.Visibility
    }
  }
}
